/*
 * lrs -- longest repeat substring
 * @Sheng Yi	2012/09/20
 */
#include <stdio.h>
#include <string.h>

/*
 * ugly but directly! List all situations.
 * when we want to solve some problem elegantly, we should first find way to finish it.  
 * here, we just print it.
 */
int lrs_length_normal(char* input, int* pos)
{
	int len = strlen(input);	
	int i, j, k, spos;
	for (i = len / 2; i > 1; i--)
	{
		// Find the substring whoes length is i
		for (j = 0; j < len - i; j++)
		{
			for (k = j + i; k < len - i; k++)
			{
				spos = 0;
				while (spos < i)
				{
					if (input[j + pos] != input[k + pos])
						break;
				}
				if (spos == i)
				{
					*pos = j;
					return i;
				}
			}
		}
	}
}


